use crate::cli::package::package::{package_run, PackageSubcommand};
use crate::cli::project::project::{project_run, ProjectSubcommand};
use crate::cli::sim::sim::{sim_run, SimSubcommand};
use crate::cli::trace::trace::{trace_run, TraceSubcommand};
use crate::cli::user::user::{user_run, UserSubcommand};
use clap::{Parser, Subcommand};

///develop io的帮助信息。
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Dio {
    #[command(subcommand)]
    cmd: Command,
}

#[derive(Subcommand)]
enum Command {
    ///项目管理类操作。
    Project {
        #[command(subcommand)]
        project: ProjectSubcommand,
    },
    ///仿真平台操作。
    Sim {
        #[command(subcommand)]
        sim: SimSubcommand,
    },
    ///包管理操作。
    Package {
        #[command(subcommand)]
        package: PackageSubcommand,
    },
    ///用户管理操作。
    User {
        #[command(subcommand)]
        user: UserSubcommand,
    },
    ///授权管理操作。
    Auth { auth: () },
    ///develop io的主页工具。
    Home { home: () },
    ///国际化操作。
    I18n { i18n: () },
    ///数据跟踪类操作。
    Trace {
        #[command(subcommand)]
        trace: TraceSubcommand,
    },
}

pub fn run() {
    let dio = Dio::parse();
    if let cmd = dio.cmd {
        match cmd {
            Command::Project { project } => project_run(project),
            Command::Sim { sim } => {
                sim_run(sim);
            }
            Command::Package { package } => package_run(package),
            Command::User { user } => user_run(user),
            Command::Auth { auth } => {
                println!("暂未支持的指令");
            }
            Command::Home { home } => {
                println!("暂未支持的指令");
            }
            Command::I18n { i18n } => {
                println!("暂未支持的指令");
            }
            Command::Trace { trace } => trace_run(trace),
        }
    }
}
